package com.haiyou.common.spring.mvc;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.async.TimeoutCallableProcessingInterceptor;
import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.haiyou.common.spring.schedule.ScheduledExecutor;


/**
 * 
 * @Description: 配置异步支持
 * @author xingyuan
 * @date 2022年8月23日 下午2:39:05
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

	@Override
	public void configureAsyncSupport(final AsyncSupportConfigurer configurer) {
		configurer.setDefaultTimeout(10 * 1000L);
		configurer.registerCallableInterceptors(timeoutInterceptor());
		//configurer.setTaskExecutor(ScheduledExecutor.getInstance().getScheduler());
	}

	public TimeoutCallableProcessingInterceptor timeoutInterceptor() {
		return new TimeoutCallableProcessingInterceptor();
	}
}
